package main

import (
	"fmt"
	"github.com/urfave/cli/v2"
	"os"
	models "yak/cmd/user-center/model"
	"yak/config"

	"yak/util/apollo"
)

func init() {
	apollo.Setup()
}

func main() {
	appConf := config.GetAppInfo()

	app := cli.NewApp()
	app.Name = appConf.Name
	app.Usage = appConf.Usage

	app.Action = apiAction

	if err := app.Run(os.Args); err != nil {
		fmt.Printf("服务启动失败，错误信息: %s", err)
		os.Exit(1)
	}
}

func apiAction(c *cli.Context) error {
	mysqlInfo := config.GetMysqlInfo()
	models.Setup(mysqlInfo.User, mysqlInfo.Password, mysqlInfo.Host, mysqlInfo.DbName)

	return nil
}
